package com.qbw.core.base;


import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

/**
 * @author qinbaowei
 * @createtime 2017/03/22 17:45
 * @email qbaowei@qq.com
 * @description
 */


public abstract class BaseFragmentPagerAdapter<T> extends FragmentPagerAdapter {

    protected List<T> mTs;

    public BaseFragmentPagerAdapter(FragmentManager fm, List ts) {
        super(fm);
        mTs = ts;
    }

    @Override
    public int getCount() {
        return mTs == null ? 0 : mTs.size();
    }

    public void addItemT(T t) {
        mTs.add(t);
        notifyDataSetChanged();
    }

    public void addItemTs(List<T> ts) {
        mTs.addAll(ts);
        notifyDataSetChanged();
    }

    public T getItemT(int position) {
        return mTs.get(position);
    }

}
